import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn,ManyToOne } from 'typeorm'
import {UserEntity} from '../user/user.entity'
@Entity({ name: 'posts' })
export class PostsEntity {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'id',
    comment: '主键id'
  })
  id: number

  @Column({
    type: 'varchar',
    length: 11,
    unique: true,
    nullable: false,
    name: 'title',
    comment: '文章标题'
  })
  title: string

  @Column({
    type: "varchar",
    length: 300,
    unique: false,
    nullable: true,
    name: 'content',
    comment: '文章内容'
  })
  content: string

  @Column({
    type: 'tinyint',
    default: () => 0,
    name: 'is_del',
    comment: '是否可以删除，0-可以，1-不可以'
  })
  isDel: number

  @CreateDateColumn({
    type: 'timestamp',
    name: 'create_time',
    comment: '创建时间',
    unique: false,
    nullable: true,
  })
  createTime: Date

  @UpdateDateColumn({
    type: 'timestamp',
    name: 'update_time',
    comment: '更新时间',
    unique: false,
    nullable: true,
  })
  updateTime: Date

@ManyToOne(type=>UserEntity,user=>user.posts)
user:UserEntity
}